home *** CD-ROM | disk | FTP | other *** search
/ Champak 145 / (Vol 145) Dec 21 2011.iso / Games / hearts.swf / scripts / DefineSprite_638 / frame_1 / DoAction_9.as < prev    next >
Encoding:
Text File  |  2011-12-21  |  3.6 KB  |  146 lines

  1. this.heartA = new Array();
  2. this.createHeartFlakes = function()
  3. {
  4.    var t = this;
  5.    var i = 1;
  6.    while(i < 10)
  7.    {
  8.       t.bg.attachMovie("heart","h" + i,i);
  9.       var n = t.bg["h" + i];
  10.       n._x = random(t.stageW);
  11.       n._y = random(t.stageH);
  12.       n._xscale = n._yscale = random(200) + 400;
  13.       n._alpha = 15;
  14.       n._rotation = random(60) - 30;
  15.       n.w2 = n._width / 2;
  16.       n.h2 = n._height / 2;
  17.       n.mx = Math.random() * 2 - 1;
  18.       n.typ = "hf";
  19.       t.heartA.push(n);
  20.       i++;
  21.    }
  22. };
  23. this.createHeart = function()
  24. {
  25.    var t = this;
  26.    t.attachMovie("heart","h" + t.hd,t.hd);
  27.    var n = t["h" + t.hd];
  28.    n._y = (- n._height) / 2;
  29.    n._xscale = n._yscale = t.heartSize;
  30.    n.typ = "heart";
  31.    t.htim = 0;
  32.    if(t.comboCount == 0)
  33.    {
  34.       if(t.gameType == "real")
  35.       {
  36.          n._x = random(t.stageW - t.startX) + t.startX - n._width / 2;
  37.       }
  38.       else
  39.       {
  40.          n._x = t.startX + random(80) + 30;
  41.       }
  42.       var distB = 0.15 * Math.round((point.x - t.startX) / t.heartStageW);
  43.       n.my = Math.random() * 0.6 + 0.25 + t.timer / 20000 - distB;
  44.       var c = t.timer / 300;
  45.       t.hdel = 150 - c - random(30);
  46.       if(t.hdel < 0)
  47.       {
  48.          t.hdel = 20;
  49.       }
  50.    }
  51.    else
  52.    {
  53.       t.hdel = 35 - 2 * t.comboCount - t.timer / 300;
  54.       n._x = t.comboCount * 50 + t.startX - 90;
  55.       n._xscale = n._yscale = 130;
  56.       n.my = 0.4 + t.timer / 20000;
  57.       t.comboCount = t.comboCount + 1;
  58.       if(t.comboCount > 10)
  59.       {
  60.          t.comboCount = 0;
  61.          t.gameDisplay.p6._alpha = t.initPUAlpha;
  62.       }
  63.    }
  64.    t.addD("h");
  65.    t.heartA.push(n);
  66. };
  67. this.moveH = function()
  68. {
  69.    var t = this;
  70.    var i = t.heartA.length - 1;
  71.    while(i >= 0)
  72.    {
  73.       var n = t.heartA[i];
  74.       n._y += t.hmyc * n.my;
  75.       if(n.typ == "hf")
  76.       {
  77.          n._x += n.mx;
  78.          if(t.grav != 0)
  79.          {
  80.             n.my = Math.random() * 2 + t.grav;
  81.          }
  82.          else
  83.          {
  84.             n.my = 0;
  85.          }
  86.          if(n._y > t.stageH + n.h2)
  87.          {
  88.             n._x = random(t.stageW);
  89.             n._y = - n.h2;
  90.             n._xscale = n._yscale = random(200) + 400;
  91.             n._alpha = 20;
  92.             n._rotation = random(60) - 30;
  93.             n.w2 = n._width / 2;
  94.             n.h2 = n._height / 2;
  95.             n.mx = Math.random() * 2 - 1;
  96.          }
  97.          if(n._x < - n.w2)
  98.          {
  99.             n._x = t.stageW + n.w2;
  100.          }
  101.          else if(n._x > t.stageW + n.w2)
  102.          {
  103.             n._x = - n.w2;
  104.          }
  105.       }
  106.       else if(n.typ == "heart")
  107.       {
  108.          if(n._y > t.stageH - n._height / 2)
  109.          {
  110.             n._y = t.stageH - n._height / 2;
  111.             t.numLives--;
  112.             t.gameDisplay["h" + t.numLives]._visible = false;
  113.             if(t.soundPlay == "true")
  114.             {
  115.                t.breakSound.start();
  116.             }
  117.             t.attachMovie("shatter","s" + t.hd,t.hd);
  118.             var m = t["s" + t.hd];
  119.             m._xscale = m._yscale = n._xscale;
  120.             m._x = n._x;
  121.             m._y = n._y;
  122.             t.addD("h");
  123.             n.removeMovieClip();
  124.             t.heartA.splice(i,1);
  125.             if(t.numLives == 0)
  126.             {
  127.                t.gameOverFunc();
  128.             }
  129.          }
  130.       }
  131.       else if(n.typ == "pu")
  132.       {
  133.          if(n._y > t.stageH + n._height / 2)
  134.          {
  135.             n.removeMovieClip();
  136.             t.heartA.splice(i,1);
  137.          }
  138.       }
  139.       else if(n.typ == "fly")
  140.       {
  141.          n._x += t.hmyc * n.my;
  142.       }
  143.       i--;
  144.    }
  145. };
  146.